<?php
$ta="2009/2010";
$sem="1";
include_once "test5.php";

echo "<table border='1' style='text-align:center;'>";
echo "<tr>";
for ($x=1;$x<=31;$x++)				//++
{echo "<td>".$x."</td>";}
echo "</tr>";
$a=1;
for($b=1;$b<=31;$b++){
echo "<td>";
echo $cek[$b]=$krom[$a][$b]=mt_rand(1, 35);
echo "</td>";
}
echo "</table>";

$unik = array_unique($cek);	//dapetin angka unik
$hitung = count($unik);			//hitung ada berapa angka unik
foreach ($unik as &$value) {	//rubah angka unik; array() => array[]
    $unik2[]=$value;
	echo $value.";";
}unset($value);
echo "unik2<br />";   //------
$jumlah = array_count_values($cek);	//hitung banyaknya tiap angka unik
print_r($jumlah);
echo "jumlah<br />";   //------
foreach ($jumlah as &$value) {	//rubah banyaknya angka unik; array() => array[]
    $jumlah2[]=$value;
	echo $value.";";
}unset($value);
echo "jumlah2<br />";   //------
print_r($unik);
echo "unik<br />";   //------
echo "<br/>".$hitung."<br/>";
echo "hitung<br />";   //------



for($bnt=0;$bnt<$hitung;$bnt++){					//urutan buat fitness 3
$jml_bnt=$jumlah2[$bnt];
$unik_bnt=$unik2[$bnt];

if ($jml_bnt<=1){}
elseif ($jml_bnt<=2)
				{
				//echo $unik_bnt." :";
				//echo "ada 2 ";
				$knci=array_keys($cek, $unik_bnt);
				foreach ($knci as &$value) {	//dimana angka unik; array() => array[]
					$knci2[]=$value;
					}
				$pintu1=$knci2[0];$pintu2=$knci2[1];
				//echo $pintu1;echo " : ".$pintu2." = ";
				$fit_bnt[$bnt]= $hasil2[$pintu1][$pintu2]*10;
				//if ($bndg_bnt0>=1){$fit_bnt[$bnt]="10";}
				//else {echo " g bentrok<br />";}
				//echo $fit_bnt[$bnt]."<br />";
				unset($value);unset($knci);unset($knci2);
				}
elseif ($jml_bnt<=3)
				{
				//echo $unik_bnt." :";
				//echo "ada 3 ";
				$knci=array_keys($cek, $unik_bnt);
				foreach ($knci as &$value) {	//dimana angka unik; array() => array[]
					$knci2[]=$value;
					}
				$jndela1=$knci2[0];$jndela2=$knci2[1];$jndela3=$knci2[2];
				//echo $jndela1;echo " : ".$jndela2;echo " : ".$jndela3." = ";
				$fit_bnt1 = $hasil2[$jndela1][$jndela2] * 10;
				$fit_bnt2 = $hasil2[$jndela1][$jndela3] * 10;
				$fit_bnt3 = $hasil2[$jndela2][$jndela3] * 10;
				$fit_bnt[$bnt] = $fit_bnt1+$fit_bnt2+$fit_bnt3."<br />";
				//echo $fit_bnt[$bnt]
				unset($value);unset($knci);unset($knci2);
				}
else {$fit_bnt[$bnt]="40";}
}

$fit_bnt_tot=array_sum($fit_bnt);

/*
for($muat=0;$muat<$hitung;$muat++){					//urutan buat fitness 4 
$jml_muat=$jumlah2[$muat];
$unik_muat=$unik2[$muat];

if ($jml_muat<=1){}
elseif ($jml_muat<=2)
				{
				//echo $unik_muat." :";
				//echo "ada 2 ";
				$knci=array_keys($cek, $unik_muat);
				foreach ($knci as &$value) {	//dimana angka unik; array() => array[]
					$knci2[]=$value;
					}
				$pintu1=$knci2[0];$pintu2=$knci2[1];
				//echo $pintu1;echo " : ".$pintu2;
				//$bndg_muat=$hasil2[$pintu1][$pintu2];
				//if ($bndg_muat>=1){echo " bentrok<br />";}
				//else {echo " g bentrok<br />";}
				unset($value);unset($knci);unset($knci2);
				}
elseif ($jml_muat<=3)
				{
				//echo $unik_muat." :";
				//echo "ada 3 ";
				$knci=array_keys($cek, $unik_muat);
				foreach ($knci as &$value) {	//dimana angka unik; array() => array[]
					$knci2[]=$value;
					}
				$jndela1=$knci2[0];$jndela2=$knci2[1];$jndela3=$knci2[2];
				//echo $jndela1;echo " : ".$jndela2;echo " : ".$jndela3."<br />";
				unset($value);unset($knci);unset($knci2);
				}
else {}
}
*/

?>